home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20020314-20021006 / 000372_fdc@columbia.edu_Wed Sep 18 09:28:28 EDT 2002.msg < prev    next >
Text File  |  2020-01-01  |  5KB  |  166 lines

  1. Article: 13706 of comp.protocols.kermit.misc
  2. Path: newsmaster.cc.columbia.edu!news.columbia.edu!news-not-for-mail
  3. From: fdc@columbia.edu (Frank da Cruz)
  4. Newsgroups: comp.protocols.kermit.misc
  5. Subject: Re: scripting to a serial sms modem - idiot question!
  6. Date: 18 Sep 2002 09:27:44 -0400
  7. Organization: Columbia University
  8. Lines: 149
  9. Message-ID: <am9v0g$t1e$1@watsol.cc.columbia.edu>
  10. References: <e516d9ec.0209160537.450ca7b@posting.google.com> <am4nq6$p5i$1@watsol.cc.columbia.edu> <e516d9ec.0209180309.320f7dad@posting.google.com>
  11. NNTP-Posting-Host: watsol.cc.columbia.edu
  12. X-Trace: newsmaster.cc.columbia.edu 1032355665 25626 128.59.39.139 (18 Sep 2002 13:27:45 GMT)
  13. X-Complaints-To: postmaster@columbia.edu
  14. NNTP-Posting-Date: 18 Sep 2002 13:27:45 GMT
  15. Xref: newsmaster.cc.columbia.edu comp.protocols.kermit.misc:13706
  16.  
  17. In article <e516d9ec.0209180309.320f7dad@posting.google.com>,
  18. Mark Swarbrick <mswarbrick@rentokil.com> wrote:
  19. : ...
  20. : The modem used is a siemens tc35 terminal. SMS commands may vary. I am
  21. : now working on two way scripts so that actions can be performed on the
  22. : pc depending on the text of a message, then a specific message sent
  23. : back. Eg if i text uptime to the sms box, i want a text message back
  24. : with the uptime of the server. Now i've just got to learn some more
  25. : i/o commands!
  26. INPUT or MINPUT to get text from the device, OUTPUT to send it, and then
  27. there are myriad string-processing functions to deal with the text.
  28.  
  29. : There is a website which has two dialogue boxes for number and
  30. : message. This will then write a physical file on the outward facing
  31. : webserver. This file contains the number and message wrapped with the
  32. : correct string
  33. : eg lineout at+cmgs"+44123456789"
  34. : The internal machine with the sms modem attached runs a script from a
  35. : cron every minute.
  36. : -----------
  37. : #!/bin/bash
  38. : #runs ftp commands from the ftpget file to get msg file off remote
  39. : webserver
  40. : /bin/cat /tmp/ftpget | /usr/bin/ftp -i -n     
  41. Of course you can use Kermit for this too:
  42.  
  43.   http://www.columbia.edu/kermit/ftpscripts.html
  44.  
  45. : #runs another script which appends a header and footer to the message
  46. : file. The #header is just stuff like the kerbang line and setting the
  47. : modem port/speed #etc. The footer is simply a quit statement.
  48. : /tmp/batchscript.sh
  49. You can do this with Kermit too.  (So in short, the entire process can
  50. be a single Kermit script.)
  51.  
  52. : #outbox.sms is created which contains the full command list needed to
  53. : send the #sms
  54. : chmod +x /tmp/outbox.sms
  55. : #Execute the kermit kebang script
  56. : /tmp/outbox.sms
  57. : echo y|rm /tmp/outbox.sms
  58. : -------------
  59. : The final outbox.sms file looks like this:
  60. A few minor comments...
  61.  
  62. : #!/usr/bin/kermit
  63. : set modem type usr
  64. :
  65. Strictly speaking you don't have to tell Kermit what kind of modem
  66. it is, since you never issue a DIAL command.
  67.  
  68. : set line /dev/ttyS0
  69. :
  70. You need an IF FAILURE clause here in case you can't open the device.
  71. This might be a loop that retries periodically.
  72.  
  73. : set speed 9600
  74. : set carrier-watch off
  75. : set input echo on
  76. : lineout at
  77. : input 20 ok
  78. :
  79. Here again, you want an IF FAILURE clause to make sure the modem is
  80. paying attention and answering.  Also, note that your INPU command
  81. assumes the modem is in verbose response mode, which is not the
  82. only possibility.  If you want to be certain, use:
  83.  
  84.   lineout ATQ0V1
  85.  
  86. Next you have a series of LINOUT and INPUT commands.  You can check
  87. each INPUT with IF FAIL, or you can insert:
  88.  
  89.   set take error on
  90.  
  91. at this point to have the script fail automatically if any subsequent
  92. command fails.
  93.  
  94. : lineout AT+CMGF=1
  95. : input 20 ok
  96. : lineout AT+CMGS="+447747603208"^M
  97. :
  98. I assume the "^M" here and in the following are mistakes...
  99.  
  100. : input 20 >^M
  101. : lineout 1^M
  102. : output \26^M
  103. : input 100 ok
  104. : lineout AT+CMGS="+447747603208"^M
  105. : input 20 >^M
  106. : lineout 2^M
  107. : output \26^M
  108. : input 100 ok
  109. : lineout AT+CMGS="+447747603208"^M
  110. : input 20 >^M
  111. : lineout 3^M
  112. : output \26^M
  113. : quit
  114. : In this example 3 messages are sent, with the text '1','2','3'
  115. : respectively.
  116. Of course this could be done as a loop, with arrays, e.g.:
  117.  
  118.   declare \&m[] = "message one" "message two" "message three"
  119.  
  120.   for \%i \fdim(&m) 1 {
  121.       lineout AT+CMGS="+447747603208"
  122.       input 20 >
  123.       if success {
  124.       lineout AT+CMGS="\&m[\%i]"
  125.       input 20 >
  126.       if success {
  127.           output \26
  128.           input 100 OK
  129.           if success continue
  130.       }
  131.   }
  132.   if > \%i \fdim(&m) exit 0
  133.   exit 1 "Message \%i failed: "\&m[\%i]"
  134.  
  135. : hope this helps someone, let me know what you think frank and if
  136. : you've got any links that might be useful!
  137. :
  138. Maybe some other SMS users will jump in.
  139.  
  140. As far as Kermit scripting, there is script tutorial and library:
  141.  
  142.   http://www.columbia.edu/kermit/ckscripts.html
  143.  
  144. The manual:
  145.  
  146.   http://www.columbia.edu/kermit/ck60manual.html
  147.  
  148. And the C-Kermit 7.0 and 8.0 manual updates:
  149.  
  150.   http://www.columbia.edu/kermit/ckermit70.html
  151.   http://www.columbia.edu/kermit/ckermit80.html
  152.  
  153. - Frank
  154.